{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "http://www.stat.yale.edu/Courses/1997-98/101/linreg.htm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "import numpy as np\n",
    "import keras\n",
    "\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "from keras.layers import Input, Dense\n",
    "from keras.models import Model\n",
    "\n",
    "from sklearn.preprocessing import StandardScaler, MinMaxScaler, Normalizer\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv(\"../television/data.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>Life Expectancy</th>\n",
       "      <th>People per Television</th>\n",
       "      <th>People per Physician</th>\n",
       "      <th>Female Life Expectancy</th>\n",
       "      <th>Male Life Expectancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Argentina</td>\n",
       "      <td>70.5</td>\n",
       "      <td>4</td>\n",
       "      <td>370</td>\n",
       "      <td>74</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Bangladesh</td>\n",
       "      <td>53.5</td>\n",
       "      <td>315</td>\n",
       "      <td>6166</td>\n",
       "      <td>53</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brazil</td>\n",
       "      <td>65.0</td>\n",
       "      <td>4</td>\n",
       "      <td>684</td>\n",
       "      <td>68</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Canada</td>\n",
       "      <td>76.5</td>\n",
       "      <td>1.7</td>\n",
       "      <td>449</td>\n",
       "      <td>80</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>China</td>\n",
       "      <td>70.0</td>\n",
       "      <td>8</td>\n",
       "      <td>643</td>\n",
       "      <td>72</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Country  Life Expectancy People per Television  People per Physician  \\\n",
       "0   Argentina             70.5                     4                   370   \n",
       "1  Bangladesh             53.5                   315                  6166   \n",
       "2      Brazil             65.0                     4                   684   \n",
       "3      Canada             76.5                   1.7                   449   \n",
       "4       China             70.0                     8                   643   \n",
       "\n",
       "   Female Life Expectancy  Male Life Expectancy  \n",
       "0                      74                    67  \n",
       "1                      53                    54  \n",
       "2                      68                    62  \n",
       "3                      80                    73  \n",
       "4                      72                    68  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(Index(['Country', 'Life Expectancy', 'People per Television',\n",
       "        'People per Physician', 'Female Life Expectancy',\n",
       "        'Male Life Expectancy'],\n",
       "       dtype='object'), Country                    object\n",
       " Life Expectancy           float64\n",
       " People per Television      object\n",
       " People per Physician        int64\n",
       " Female Life Expectancy      int64\n",
       " Male Life Expectancy        int64\n",
       " dtype: object)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns,df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# df[\"People per Television\"] = df[\"People per Television\"].as_numeric\n",
    "df[\"People per Television\"] = pd.to_numeric(df[\"People per Television\"],errors='coerce')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = df.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>Life Expectancy</th>\n",
       "      <th>People per Television</th>\n",
       "      <th>People per Physician</th>\n",
       "      <th>Female Life Expectancy</th>\n",
       "      <th>Male Life Expectancy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Argentina</td>\n",
       "      <td>70.5</td>\n",
       "      <td>4.0</td>\n",
       "      <td>370</td>\n",
       "      <td>74</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Bangladesh</td>\n",
       "      <td>53.5</td>\n",
       "      <td>315.0</td>\n",
       "      <td>6166</td>\n",
       "      <td>53</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Brazil</td>\n",
       "      <td>65.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>684</td>\n",
       "      <td>68</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Canada</td>\n",
       "      <td>76.5</td>\n",
       "      <td>1.7</td>\n",
       "      <td>449</td>\n",
       "      <td>80</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>China</td>\n",
       "      <td>70.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>643</td>\n",
       "      <td>72</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Country  Life Expectancy  People per Television  People per Physician  \\\n",
       "0   Argentina             70.5                    4.0                   370   \n",
       "1  Bangladesh             53.5                  315.0                  6166   \n",
       "2      Brazil             65.0                    4.0                   684   \n",
       "3      Canada             76.5                    1.7                   449   \n",
       "4       China             70.0                    8.0                   643   \n",
       "\n",
       "   Female Life Expectancy  Male Life Expectancy  \n",
       "0                      74                    67  \n",
       "1                      53                    54  \n",
       "2                      68                    62  \n",
       "3                      80                    73  \n",
       "4                      72                    68  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((38, 1), (38, 1))"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# x = ppl/television\n",
    "# y = ppl/doctor\n",
    "\n",
    "x = df[\"People per Television\"].values.reshape(-1,1).astype(np.float64)\n",
    "y = df[\"People per Physician\"].values.reshape(-1,1).astype(np.float64)\n",
    "\n",
    "x.shape,y.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/10\n",
      "38/38 [==============================] - 0s - loss: 0.8160      \n",
      "Epoch 2/10\n",
      "38/38 [==============================] - 0s - loss: 0.7883     \n",
      "Epoch 3/10\n",
      "38/38 [==============================] - 0s - loss: 0.7916     \n",
      "Epoch 4/10\n",
      "38/38 [==============================] - 0s - loss: 0.7954     \n",
      "Epoch 5/10\n",
      "38/38 [==============================] - 0s - loss: 0.7973     \n",
      "Epoch 6/10\n",
      "38/38 [==============================] - 0s - loss: 0.7981     \n",
      "Epoch 7/10\n",
      "38/38 [==============================] - 0s - loss: 0.7985     \n",
      "Epoch 8/10\n",
      "38/38 [==============================] - 0s - loss: 0.7986     \n",
      "Epoch 9/10\n",
      "38/38 [==============================] - 0s - loss: 0.7987     \n",
      "Epoch 10/10\n",
      "38/38 [==============================] - 0s - loss: 0.7987     \n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7fd5447e65f8>]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAEACAYAAABBDJb9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFQtJREFUeJzt3XuQnFWZx/HfEzITGsKAwASUy8zqyiKgghYGjZdmIchF\nBay12KAFBaOUFhQ3i1JZtxi1kJIquVRJiZYNisCgiyshIBAQegUWwqzhEkIQcJkQ2CTVECoCGZyB\nPPtH96RnhmTmfadP99t9+vupmqKn5z3nPU3gN09On3Pa3F0AgNY2K+sBAABqR5gDQAQIcwCIAGEO\nABEgzAEgAoQ5AEQgSJib2c5m9h9mtsrMVprZ/BD9AgCSmR2onysl/cHdv2RmsyXtEKhfAEACVuum\nITPrkvSou78vzJAAAGmFm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JpoiQ2GaH1mNlcSTdLOqdSoUfD3TdLOsTMuiTdYmYHuHvLT0uY2XGS1rv7\nY2aWVzx/2x9vgbuvNbNuSXeb2arK35a3KniYu/vC0H02sZck7Tvu+70rz6FFmNlslYP81+6+OOvx\n1Iu7/62yue9oxTHHvEDSF8zsWEk5STuZ2XXufkrG4wrG3ddW/lkys9+rPK27zTDPcpolht+kg5L+\n0cx6zKxT0r9Kiu1ddVMcf1bbco2kp9z9yqwHEpqZ7W5mO1ce5yQtlPR0tqMKw90vdPd93f29Kv9/\nd29MQW5mO1T+xigz21HSUZKenKpNo5cmRrXJyN3flnSWpKWSVkq6yd1XZTuqcMzsRkn/LWk/M3vB\nzE7LekwhmdkCSV+W9M+V5V/LzezorMcV0Lsl3Wdmj6n8XsBd7v6HjMeEZPaQ9EDl/Y6HJS1x96VT\nNWDTEABEgNUsABABwhwAIkCYA0AECHMAiABhDgARIMwBIAKEOQBEgDAHgAj8P7H3H2PsF037AAAA\nAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fd555415208>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sc = StandardScaler()\n",
    "x_ = sc.fit_transform(x)\n",
    "y_ = sc.fit_transform(y)\n",
    "\n",
    "inputs = Input(shape=(1,))\n",
    "preds = Dense(1,activation='linear')(inputs)\n",
    "\n",
    "model = Model(inputs=inputs,outputs=preds)\n",
    "sgd=keras.optimizers.SGD()\n",
    "model.compile(optimizer=sgd ,loss='mse')\n",
    "model.fit(x_,y_, batch_size=1, verbose=1, epochs=10, shuffle=False)\n",
    "plt.scatter(x_,y_,color='black')\n",
    "plt.plot(x_,model.predict(x_), color='blue', linewidth=3)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Global TF Kernel (Python 3)",
   "language": "python",
   "name": "global-tf-python-3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
